/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package EA_Model.IEC61970.Wires.impl;

import EA_Model.IEC61970.Domain.AngleDegrees;
import EA_Model.IEC61970.Domain.Reactance;
import EA_Model.IEC61970.Domain.Voltage;

import EA_Model.IEC61970.Wires.PhaseTapChanger;
import EA_Model.IEC61970.Wires.PhaseTapChangerKind;
import EA_Model.IEC61970.Wires.WiresPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Phase Tap Changer</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.PhaseTapChangerImpl#getNominalVoltageOutOfPhase <em>Nominal Voltage Out Of Phase</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.PhaseTapChangerImpl#getPhaseTapChangerType <em>Phase Tap Changer Type</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.PhaseTapChangerImpl#getStepPhaseShiftIncrement <em>Step Phase Shift Increment</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.PhaseTapChangerImpl#getVoltageStepIncrementOutOfPhase <em>Voltage Step Increment Out Of Phase</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.PhaseTapChangerImpl#getWindingConnectionAngle <em>Winding Connection Angle</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.PhaseTapChangerImpl#getXStepMax <em>XStep Max</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.PhaseTapChangerImpl#getXStepMin <em>XStep Min</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PhaseTapChangerImpl extends TapChangerImpl implements PhaseTapChanger {
	/**
	 * The cached value of the '{@link #getNominalVoltageOutOfPhase() <em>Nominal Voltage Out Of Phase</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNominalVoltageOutOfPhase()
	 * @generated
	 * @ordered
	 */
	protected Voltage nominalVoltageOutOfPhase;

	/**
	 * The default value of the '{@link #getPhaseTapChangerType() <em>Phase Tap Changer Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPhaseTapChangerType()
	 * @generated
	 * @ordered
	 */
	protected static final PhaseTapChangerKind PHASE_TAP_CHANGER_TYPE_EDEFAULT = PhaseTapChangerKind.ASYMMETRICAL;

	/**
	 * The cached value of the '{@link #getPhaseTapChangerType() <em>Phase Tap Changer Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPhaseTapChangerType()
	 * @generated
	 * @ordered
	 */
	protected PhaseTapChangerKind phaseTapChangerType = PHASE_TAP_CHANGER_TYPE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getStepPhaseShiftIncrement() <em>Step Phase Shift Increment</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStepPhaseShiftIncrement()
	 * @generated
	 * @ordered
	 */
	protected AngleDegrees stepPhaseShiftIncrement;

	/**
	 * The cached value of the '{@link #getVoltageStepIncrementOutOfPhase() <em>Voltage Step Increment Out Of Phase</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getVoltageStepIncrementOutOfPhase()
	 * @generated
	 * @ordered
	 */
	protected Voltage voltageStepIncrementOutOfPhase;

	/**
	 * The cached value of the '{@link #getWindingConnectionAngle() <em>Winding Connection Angle</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWindingConnectionAngle()
	 * @generated
	 * @ordered
	 */
	protected AngleDegrees windingConnectionAngle;

	/**
	 * The cached value of the '{@link #getXStepMax() <em>XStep Max</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXStepMax()
	 * @generated
	 * @ordered
	 */
	protected Reactance xStepMax;

	/**
	 * The cached value of the '{@link #getXStepMin() <em>XStep Min</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXStepMin()
	 * @generated
	 * @ordered
	 */
	protected Reactance xStepMin;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PhaseTapChangerImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WiresPackage.Literals.PHASE_TAP_CHANGER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage getNominalVoltageOutOfPhase() {
		if (nominalVoltageOutOfPhase != null && nominalVoltageOutOfPhase.eIsProxy()) {
			InternalEObject oldNominalVoltageOutOfPhase = (InternalEObject)nominalVoltageOutOfPhase;
			nominalVoltageOutOfPhase = (Voltage)eResolveProxy(oldNominalVoltageOutOfPhase);
			if (nominalVoltageOutOfPhase != oldNominalVoltageOutOfPhase) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.PHASE_TAP_CHANGER__NOMINAL_VOLTAGE_OUT_OF_PHASE, oldNominalVoltageOutOfPhase, nominalVoltageOutOfPhase));
			}
		}
		return nominalVoltageOutOfPhase;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage basicGetNominalVoltageOutOfPhase() {
		return nominalVoltageOutOfPhase;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNominalVoltageOutOfPhase(Voltage newNominalVoltageOutOfPhase) {
		Voltage oldNominalVoltageOutOfPhase = nominalVoltageOutOfPhase;
		nominalVoltageOutOfPhase = newNominalVoltageOutOfPhase;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.PHASE_TAP_CHANGER__NOMINAL_VOLTAGE_OUT_OF_PHASE, oldNominalVoltageOutOfPhase, nominalVoltageOutOfPhase));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PhaseTapChangerKind getPhaseTapChangerType() {
		return phaseTapChangerType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPhaseTapChangerType(PhaseTapChangerKind newPhaseTapChangerType) {
		PhaseTapChangerKind oldPhaseTapChangerType = phaseTapChangerType;
		phaseTapChangerType = newPhaseTapChangerType == null ? PHASE_TAP_CHANGER_TYPE_EDEFAULT : newPhaseTapChangerType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.PHASE_TAP_CHANGER__PHASE_TAP_CHANGER_TYPE, oldPhaseTapChangerType, phaseTapChangerType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AngleDegrees getStepPhaseShiftIncrement() {
		if (stepPhaseShiftIncrement != null && stepPhaseShiftIncrement.eIsProxy()) {
			InternalEObject oldStepPhaseShiftIncrement = (InternalEObject)stepPhaseShiftIncrement;
			stepPhaseShiftIncrement = (AngleDegrees)eResolveProxy(oldStepPhaseShiftIncrement);
			if (stepPhaseShiftIncrement != oldStepPhaseShiftIncrement) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.PHASE_TAP_CHANGER__STEP_PHASE_SHIFT_INCREMENT, oldStepPhaseShiftIncrement, stepPhaseShiftIncrement));
			}
		}
		return stepPhaseShiftIncrement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AngleDegrees basicGetStepPhaseShiftIncrement() {
		return stepPhaseShiftIncrement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStepPhaseShiftIncrement(AngleDegrees newStepPhaseShiftIncrement) {
		AngleDegrees oldStepPhaseShiftIncrement = stepPhaseShiftIncrement;
		stepPhaseShiftIncrement = newStepPhaseShiftIncrement;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.PHASE_TAP_CHANGER__STEP_PHASE_SHIFT_INCREMENT, oldStepPhaseShiftIncrement, stepPhaseShiftIncrement));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage getVoltageStepIncrementOutOfPhase() {
		if (voltageStepIncrementOutOfPhase != null && voltageStepIncrementOutOfPhase.eIsProxy()) {
			InternalEObject oldVoltageStepIncrementOutOfPhase = (InternalEObject)voltageStepIncrementOutOfPhase;
			voltageStepIncrementOutOfPhase = (Voltage)eResolveProxy(oldVoltageStepIncrementOutOfPhase);
			if (voltageStepIncrementOutOfPhase != oldVoltageStepIncrementOutOfPhase) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.PHASE_TAP_CHANGER__VOLTAGE_STEP_INCREMENT_OUT_OF_PHASE, oldVoltageStepIncrementOutOfPhase, voltageStepIncrementOutOfPhase));
			}
		}
		return voltageStepIncrementOutOfPhase;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Voltage basicGetVoltageStepIncrementOutOfPhase() {
		return voltageStepIncrementOutOfPhase;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setVoltageStepIncrementOutOfPhase(Voltage newVoltageStepIncrementOutOfPhase) {
		Voltage oldVoltageStepIncrementOutOfPhase = voltageStepIncrementOutOfPhase;
		voltageStepIncrementOutOfPhase = newVoltageStepIncrementOutOfPhase;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.PHASE_TAP_CHANGER__VOLTAGE_STEP_INCREMENT_OUT_OF_PHASE, oldVoltageStepIncrementOutOfPhase, voltageStepIncrementOutOfPhase));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AngleDegrees getWindingConnectionAngle() {
		if (windingConnectionAngle != null && windingConnectionAngle.eIsProxy()) {
			InternalEObject oldWindingConnectionAngle = (InternalEObject)windingConnectionAngle;
			windingConnectionAngle = (AngleDegrees)eResolveProxy(oldWindingConnectionAngle);
			if (windingConnectionAngle != oldWindingConnectionAngle) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.PHASE_TAP_CHANGER__WINDING_CONNECTION_ANGLE, oldWindingConnectionAngle, windingConnectionAngle));
			}
		}
		return windingConnectionAngle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AngleDegrees basicGetWindingConnectionAngle() {
		return windingConnectionAngle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setWindingConnectionAngle(AngleDegrees newWindingConnectionAngle) {
		AngleDegrees oldWindingConnectionAngle = windingConnectionAngle;
		windingConnectionAngle = newWindingConnectionAngle;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.PHASE_TAP_CHANGER__WINDING_CONNECTION_ANGLE, oldWindingConnectionAngle, windingConnectionAngle));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance getXStepMax() {
		if (xStepMax != null && xStepMax.eIsProxy()) {
			InternalEObject oldXStepMax = (InternalEObject)xStepMax;
			xStepMax = (Reactance)eResolveProxy(oldXStepMax);
			if (xStepMax != oldXStepMax) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.PHASE_TAP_CHANGER__XSTEP_MAX, oldXStepMax, xStepMax));
			}
		}
		return xStepMax;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance basicGetXStepMax() {
		return xStepMax;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setXStepMax(Reactance newXStepMax) {
		Reactance oldXStepMax = xStepMax;
		xStepMax = newXStepMax;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.PHASE_TAP_CHANGER__XSTEP_MAX, oldXStepMax, xStepMax));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance getXStepMin() {
		if (xStepMin != null && xStepMin.eIsProxy()) {
			InternalEObject oldXStepMin = (InternalEObject)xStepMin;
			xStepMin = (Reactance)eResolveProxy(oldXStepMin);
			if (xStepMin != oldXStepMin) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.PHASE_TAP_CHANGER__XSTEP_MIN, oldXStepMin, xStepMin));
			}
		}
		return xStepMin;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reactance basicGetXStepMin() {
		return xStepMin;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setXStepMin(Reactance newXStepMin) {
		Reactance oldXStepMin = xStepMin;
		xStepMin = newXStepMin;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.PHASE_TAP_CHANGER__XSTEP_MIN, oldXStepMin, xStepMin));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WiresPackage.PHASE_TAP_CHANGER__NOMINAL_VOLTAGE_OUT_OF_PHASE:
				if (resolve) return getNominalVoltageOutOfPhase();
				return basicGetNominalVoltageOutOfPhase();
			case WiresPackage.PHASE_TAP_CHANGER__PHASE_TAP_CHANGER_TYPE:
				return getPhaseTapChangerType();
			case WiresPackage.PHASE_TAP_CHANGER__STEP_PHASE_SHIFT_INCREMENT:
				if (resolve) return getStepPhaseShiftIncrement();
				return basicGetStepPhaseShiftIncrement();
			case WiresPackage.PHASE_TAP_CHANGER__VOLTAGE_STEP_INCREMENT_OUT_OF_PHASE:
				if (resolve) return getVoltageStepIncrementOutOfPhase();
				return basicGetVoltageStepIncrementOutOfPhase();
			case WiresPackage.PHASE_TAP_CHANGER__WINDING_CONNECTION_ANGLE:
				if (resolve) return getWindingConnectionAngle();
				return basicGetWindingConnectionAngle();
			case WiresPackage.PHASE_TAP_CHANGER__XSTEP_MAX:
				if (resolve) return getXStepMax();
				return basicGetXStepMax();
			case WiresPackage.PHASE_TAP_CHANGER__XSTEP_MIN:
				if (resolve) return getXStepMin();
				return basicGetXStepMin();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WiresPackage.PHASE_TAP_CHANGER__NOMINAL_VOLTAGE_OUT_OF_PHASE:
				setNominalVoltageOutOfPhase((Voltage)newValue);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__PHASE_TAP_CHANGER_TYPE:
				setPhaseTapChangerType((PhaseTapChangerKind)newValue);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__STEP_PHASE_SHIFT_INCREMENT:
				setStepPhaseShiftIncrement((AngleDegrees)newValue);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__VOLTAGE_STEP_INCREMENT_OUT_OF_PHASE:
				setVoltageStepIncrementOutOfPhase((Voltage)newValue);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__WINDING_CONNECTION_ANGLE:
				setWindingConnectionAngle((AngleDegrees)newValue);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__XSTEP_MAX:
				setXStepMax((Reactance)newValue);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__XSTEP_MIN:
				setXStepMin((Reactance)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WiresPackage.PHASE_TAP_CHANGER__NOMINAL_VOLTAGE_OUT_OF_PHASE:
				setNominalVoltageOutOfPhase((Voltage)null);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__PHASE_TAP_CHANGER_TYPE:
				setPhaseTapChangerType(PHASE_TAP_CHANGER_TYPE_EDEFAULT);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__STEP_PHASE_SHIFT_INCREMENT:
				setStepPhaseShiftIncrement((AngleDegrees)null);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__VOLTAGE_STEP_INCREMENT_OUT_OF_PHASE:
				setVoltageStepIncrementOutOfPhase((Voltage)null);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__WINDING_CONNECTION_ANGLE:
				setWindingConnectionAngle((AngleDegrees)null);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__XSTEP_MAX:
				setXStepMax((Reactance)null);
				return;
			case WiresPackage.PHASE_TAP_CHANGER__XSTEP_MIN:
				setXStepMin((Reactance)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WiresPackage.PHASE_TAP_CHANGER__NOMINAL_VOLTAGE_OUT_OF_PHASE:
				return nominalVoltageOutOfPhase != null;
			case WiresPackage.PHASE_TAP_CHANGER__PHASE_TAP_CHANGER_TYPE:
				return phaseTapChangerType != PHASE_TAP_CHANGER_TYPE_EDEFAULT;
			case WiresPackage.PHASE_TAP_CHANGER__STEP_PHASE_SHIFT_INCREMENT:
				return stepPhaseShiftIncrement != null;
			case WiresPackage.PHASE_TAP_CHANGER__VOLTAGE_STEP_INCREMENT_OUT_OF_PHASE:
				return voltageStepIncrementOutOfPhase != null;
			case WiresPackage.PHASE_TAP_CHANGER__WINDING_CONNECTION_ANGLE:
				return windingConnectionAngle != null;
			case WiresPackage.PHASE_TAP_CHANGER__XSTEP_MAX:
				return xStepMax != null;
			case WiresPackage.PHASE_TAP_CHANGER__XSTEP_MIN:
				return xStepMin != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (phaseTapChangerType: ");
		result.append(phaseTapChangerType);
		result.append(')');
		return result.toString();
	}

} //PhaseTapChangerImpl
